package utils;

import enums.Gender;
import enums.LoanState;

//@author A0098891H
public class CommandGenerator {

	/**
	 * 
	 * @param name
	 * @param amount
	 * @param categoryID
	 * @param paymentModeID
	 * @param byMemberID
	 * @param paidTo
	 * @param frequency
	 * @param date
	 * @param descr
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getAddExpenseCmd(String name, double amount, int categoryID, 
			int paymentModeID, int byMemberID, String paidTo, String frequency, 
			String date, String descr)
	{
		StringBuilder sb = new StringBuilder();
		sb.append("Expense,add,");
		sb.append(name+",");
		sb.append(amount+",");
		sb.append(CommandAnalyzer.PARAM_CATEGORY+categoryID+",");
		sb.append(CommandAnalyzer.PARAM_PAYMENTMETHOD+paymentModeID+",");
		sb.append(CommandAnalyzer.PARAM_MEMBER+byMemberID+",");
		sb.append(CommandAnalyzer.PARAM_PARTYINVOLVED+paidTo+",");
		sb.append(CommandAnalyzer.PARAM_FREQUENCY+frequency+",");
		sb.append(CommandAnalyzer.PARAM_DATE+date+",");
		sb.append(CommandAnalyzer.PARAM_COMMENTS+descr);
		
		return sb.toString();
	}

	/**
	 * 
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String sendUndoCmd()
	{
		return "undo";
	}

	public static String sendRedoCmd()
	{
		return "redo";
	}
	/**
	 * 
	 * @param id
	 * @param name
	 * @param amount
	 * @param categoryID
	 * @param paymentModeID
	 * @param byMemberID
	 * @param paidTo
	 * @param frequency
	 * @param date
	 * @param descr
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getEditExpenseCmd(int id, String name, double amount, int categoryID, 
			int paymentModeID, int byMemberID, String paidTo, String frequency, 
			String date, String descr)
	{
		StringBuilder sb = new StringBuilder();
		sb.append("Expense,edit,");
		sb.append(id+",");
		sb.append(name+",");
		sb.append(amount+",");
		sb.append(CommandAnalyzer.PARAM_CATEGORY+categoryID+",");
		sb.append(CommandAnalyzer.PARAM_PAYMENTMETHOD+paymentModeID+",");
		sb.append(CommandAnalyzer.PARAM_MEMBER+byMemberID+",");
		sb.append(CommandAnalyzer.PARAM_PARTYINVOLVED+paidTo+",");
		sb.append(CommandAnalyzer.PARAM_FREQUENCY+frequency+",");
		sb.append(CommandAnalyzer.PARAM_DATE+date+",");
		sb.append(CommandAnalyzer.PARAM_COMMENTS+descr);
		
		return sb.toString();
	}
	
	
	/**
	 * 
	 * @param id
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getDeleteExpenseCmd(int id)
	{
		StringBuilder sb = new StringBuilder();
		sb.append("Expense,delete,");
		sb.append(id);
		return sb.toString();
	}
	
	
	/**
	 * 
	 * @param name
	 * @param amount
	 * @param byMemberID
	 * @param payer
	 * @param frequency
	 * @param date
	 * @param descr
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getAddIncomeCmd(String name, double amount, int byMemberID, 
			String payer, String frequency, String date, String descr)
	{	
		StringBuilder sb = new StringBuilder();
		sb.append("Income,add,");
		sb.append(name+",");
		sb.append(amount+",");
		sb.append(CommandAnalyzer.PARAM_DATE+date+",");
		sb.append(CommandAnalyzer.PARAM_MEMBER+byMemberID+",");
		sb.append(CommandAnalyzer.PARAM_PARTYINVOLVED+payer+",");
		sb.append(CommandAnalyzer.PARAM_FREQUENCY+frequency+",");
		sb.append(CommandAnalyzer.PARAM_COMMENTS+descr);
		
		return sb.toString();
	}
	
	/**
	 * 
	 * @param id
	 * @param name
	 * @param amount
	 * @param byMemberID
	 * @param payer
	 * @param frequency
	 * @param date
	 * @param descr
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getEditIncomeCmd(int id, String name, double amount, int byMemberID, 
			String payer, String frequency, String date, String descr )
	{
		StringBuilder sb = new StringBuilder();
		sb.append("Income,edit,");
		sb.append(id+",");
		sb.append(name+",");
		sb.append(amount+",");
		sb.append(CommandAnalyzer.PARAM_DATE+date+",");
		sb.append(CommandAnalyzer.PARAM_MEMBER+byMemberID+",");
		sb.append(CommandAnalyzer.PARAM_PARTYINVOLVED+payer+",");
		sb.append(CommandAnalyzer.PARAM_FREQUENCY+frequency+",");
		sb.append(CommandAnalyzer.PARAM_COMMENTS+descr);
		
		return sb.toString();
	}

	/**
	 * 
	 * @param id
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getDeleteIncomeCmd(int id)
	{
		StringBuilder sb = new StringBuilder();
		sb.append("Income,delete,");
		sb.append(id);
		return sb.toString();
	}
	
	/**
	 * 
	 * @param name
	 * @param amount
	 * @param loanState
	 * @param byMemberID
	 * @param date
	 * @param dueDate
	 * @param descr
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getAddLoanCmd(String name, double amount, LoanState loanState, int byMemberID, 
			String date, String dueDate, double interestRate, String partyInvolved, String descr)
	{	
		StringBuilder sb = new StringBuilder();
		sb.append("loan,add,");
		sb.append(name+",");
		sb.append(amount+",");
		sb.append(loanState+",");
		sb.append(CommandAnalyzer.PARAM_DATE+date+",");
		sb.append(CommandAnalyzer.PARAM_MEMBER+byMemberID+",");
		sb.append(CommandAnalyzer.PARAM_DUEDATE+dueDate+",");
		sb.append(CommandAnalyzer.PARAM_INTEREST+interestRate+",");
		sb.append(CommandAnalyzer.PARAM_PARTYINVOLVED+partyInvolved+",");
		sb.append(CommandAnalyzer.PARAM_COMMENTS+descr);	
		return sb.toString();
	}
	
	/**
	 * 
	 * @param id
	 * @param name
	 * @param amount
	 * @param loanState
	 * @param byMemberID
	 * @param date
	 * @param dueDate
	 * @param descr
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getEditLoanCmd(int id, String name, double amount, LoanState loanState,int byMemberID, 
			String date, String dueDate, double interestRate, String partyInvolved, String descr)
	{	
		StringBuilder sb = new StringBuilder();
		sb.append("loan,edit,");
		sb.append(id+",");
		sb.append(name+",");
		sb.append(amount+",");
		sb.append(loanState+",");
		sb.append(CommandAnalyzer.PARAM_DATE+date+",");
		sb.append(CommandAnalyzer.PARAM_MEMBER+byMemberID+",");
		sb.append(CommandAnalyzer.PARAM_DUEDATE+dueDate+",");
		sb.append(CommandAnalyzer.PARAM_INTEREST+interestRate+",");
		sb.append(CommandAnalyzer.PARAM_PARTYINVOLVED+partyInvolved+",");
		sb.append(CommandAnalyzer.PARAM_COMMENTS+descr);	
		return sb.toString();
	}

	/**
	 * 
	 * @param id
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getDeleteLoanCmd(int id)
	{
		StringBuilder sb = new StringBuilder();
		sb.append("loan,delete,");
		sb.append(id);
		return sb.toString();
	}
	
	/**
	 * 
	 * @param name
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getAddCategoryCmd(String name)
	{	
		StringBuilder sb = new StringBuilder();
		sb.append("category,add,");
		sb.append(name);
		return sb.toString();
	}
	
	/**
	 * 
	 * @param id
	 * @param name
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getEditCategoryCmd(int id, String name)
	{	
		StringBuilder sb = new StringBuilder();
		sb.append("category,edit,");
		sb.append(id+",");
		sb.append(name);
		return sb.toString();
	}
	/**
	 * 
	 * @param id
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getDeleteCategoryCmd(int id)
	{
		StringBuilder sb = new StringBuilder();
		sb.append("category,delete,");
		sb.append(id);
		return sb.toString();
	}
	
	/**
	 * 
	 * @param name
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getAddPaymentMethodCmd(String name)
	{	
		StringBuilder sb = new StringBuilder();
		sb.append("payment,add,");
		sb.append(name);
		return sb.toString();
	}
	
	/**
	 * 
	 * @param id
	 * @param name
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getEditPaymentMethodCmd(int id, String name)
	{	
		StringBuilder sb = new StringBuilder();
		sb.append("payment,edit,");
		sb.append(id+",");
		sb.append(name);
		return sb.toString();
	}
	/**
	 * 
	 * @param id
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getDeletePaymentMethodCmd(int id)
	{
		StringBuilder sb = new StringBuilder();
		sb.append("payment,delete,");
		sb.append(id);
		return sb.toString();
	}
	
	/**
	 * 
	 * @param name
	 * @param gender
	 * @param birthDate
	 * @param descr
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getAddMemberCmd(String name, Gender gender, String birthDate, String descr)
	{	
		StringBuilder sb = new StringBuilder();
		sb.append("member,add,");
		sb.append(name+",");
		sb.append(CommandAnalyzer.PARAM_GENDER + gender+",");
		sb.append(CommandAnalyzer.PARAM_BIRTHDATE + birthDate+",");
		sb.append(CommandAnalyzer.PARAM_COMMENTS + descr);
		return sb.toString();
	}
	
	/**
	 * 
	 * @param id
	 * @param name
	 * @param gender
	 * @param birthDate
	 * @param descr
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getEditMemberCmd(int id, String name, Gender gender, String birthDate, String descr)
	{	
		StringBuilder sb = new StringBuilder();
		sb.append("member,edit,");
		sb.append(id+",");
		sb.append(name+",");
		sb.append(CommandAnalyzer.PARAM_GENDER + gender+",");
		sb.append(CommandAnalyzer.PARAM_BIRTHDATE + birthDate+",");
		sb.append(CommandAnalyzer.PARAM_COMMENTS + descr);
		return sb.toString();
	}
	/**
	 * 
	 * @param id
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getDeleteMemberCmd(int id)
	{
		StringBuilder sb = new StringBuilder();
		sb.append("member,delete,");
		sb.append(id);
		return sb.toString();
	}
	
	//frequency: daily, weekly, monthly, yearly
	/**
	 * 
	 * @param frequency
	 * @param amount
	 * @param dateStart
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getSetBudgetCmd(String frequency, double amount, String dateStart)
	{
		StringBuilder sb = new StringBuilder();
		sb.append("budget,set,");
		sb.append(frequency+",");
		sb.append(amount+",");
		sb.append(CommandAnalyzer.PARAM_DATE+dateStart);
		return sb.toString();
	}
	
	/**
	 * 
	 * @param frequency
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getRemoveBudgetCmd(String frequency)
	{
		return "budget,remove,"+frequency;
	}
	/**
	 * 
	 * @param frequency
	 * @return
	 * @Precondition 
	 * @Postcondition 
	 */
	public static String getTurnOnBudgetCmd(String frequency)
	{
		return "budget,on,"+frequency;
	}
}
